#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main (int argc, char const* argv[])
{
    char buf[256], ch;
    int sum, i, len;

    while ('#' != (ch = getchar())) {

        i = 1; buf[0] = ch;
        while ('\n' != (buf[i++] = getchar())) ;
        buf[i-1] = '\0';

        sum = 0; len = i-1;
        for (i = 0; i < len; i++) {
            if (buf[i] != ' ') {
                sum += (i+1) * (buf[i]-'A'+1);
            }
        }

        printf("%d\n", sum);
    }

    return 0;
}
